package com.mso.BSSubtitlesDownloader.model;

import com.mso.BSSubtitlesDownloader.exceptions.RegExpException;
import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;

/**
 * Created by max on 31/03/2014.
 */
@RunWith(JUnit4.class)
public class EpisodeInfosExtracterTest {

    @Test
    public void testExecute_cas1() throws Exception {
        // TEST PUSH GIT
        EpisodeInfosExtracter episodeInfosExtracterInstance = new EpisodeInfosExtracter("american_horror.story.s03e07_720p.hdtv.x264-2hd.mkv");
        episodeInfosExtracterInstance.execute();
        EpisodeInfos episodeInfos = episodeInfosExtracterInstance.getEpisodeInfos();
        verifyAssertsEpisodeInfos(episodeInfos);
    }

    @Test
      public void testExecute_cas2() throws Exception {
        EpisodeInfosExtracter episodeInfosExtracterInstance = new EpisodeInfosExtracter("arrested.development.s04e05.720p.webrip.x264-qrus.mkv");
        episodeInfosExtracterInstance.execute();
        EpisodeInfos episodeInfos = episodeInfosExtracterInstance.getEpisodeInfos();
        verifyAssertsEpisodeInfos(episodeInfos);
    }

    @Test
    public void testExecute_casErreur1() throws Exception {
        EpisodeInfosExtracter episodeInfosExtracterInstance = new EpisodeInfosExtracter("american.horror.story.720p.hdtv.x264-2hd.mkv");

        try
        {
            episodeInfosExtracterInstance.execute();
            EpisodeInfos episodeInfos = episodeInfosExtracterInstance.getEpisodeInfos();
            Assert.fail();
        }
        catch (RegExpException e)
        {
            System.out.println("Cas d'erreur OK ! " + e.getMessage());
        }
    }

    private void verifyAssertsEpisodeInfos(EpisodeInfos episodeInfos) {
        System.out.println(episodeInfos.getNom() + " SAISON : " + episodeInfos.getSaison().toString() + " EPISODE : " + episodeInfos.getEpisode().toString());
        Assert.assertNotNull(episodeInfos);
    }
}
